import React from 'react';

import { getVersion } from '../../utils/update';

import WordsReader from '../../utils/WordsReader';
import ToolKit from '../../utils/ToolKit';
import NameGenerator from '../NameGenerator';

export default class DemoCase extends React.Component{
    componentDidMount() {
        // 请求版本信息
        // getVersion().then((res) => {
        //   console.log(res);
        // });
        // WordsReader.readWords('name-female-1.txt').then((ret) => {
        //   console.log(ret);
        // });
        // 异步
        Promise.all([WordsReader.readWords('name-female-1.txt'),
            WordsReader.readWords('name-female-2.txt')]).then((res) => {
            // 一次读两个文件
            console.log('异步：', res);
        });
        // 同步
        const data1 = WordsReader.readFileSync('name-female-1.txt');
        const data2 = WordsReader.readFileSync('name-female-2.txt');
        console.log('同步：', data1, data2);

        for(let i = 0 ; i < 100 ; i++){
            console.log(i,ToolKit.randomNumber(100));
            // console.log(ToolKit.randomNumber(1,100));
            // console.log(ToolKit.randomNumber(1,100));
        }
        const nameGeneral = new NameGenerator(-1,-1);
        nameGeneral.genNames(100)
          .then((wordsList) => {
              console.log('wordsList:',wordsList);
          });
    }

    render() {
        return (<div>
            hello, word
        </div>);
    }
}
